<?php
/**
 * Project: Recipe
 * File: CommonAction.class.php
 * Author: Xnfy520@gmail.com
 * Date: 12-4-15
 * Time: 下午9:58
 */

	class CommonAction extends Action{

		function _initialize(){

			header("Content-Type:text/html;Charset=utf-8;");

//			$foodsection = M('FoodSection');
//			$foodsections = $foodsection->field('id,name')->where('publish=1')->order('id')->select();
//			$this->assign('foodsections', $foodsections);

//			$recipesection = M('RecipeSection');
//			$recipesections = $recipesection->field('id,name,alias')->where('publish=1')->order('id')->select();
//			$this->assign('foodsections', $recipesections);

			if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
				import('ORG.Util.RBAC');
				if (!RBAC::AccessDecision()) {
					//检查认证识别号
					if (!$_SESSION [C('USER_AUTH_KEY')]) {
						//跳转到认证网关
						redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
					}
					// 没有权限 抛出错误
					if (C('RBAC_ERROR_PAGE')) {
						// 定义权限错误页面
						redirect(C('RBAC_ERROR_PAGE'));
					} else {
						if (C('GUEST_AUTH_ON')) {
							$this->assign('jumpUrl', PHP_FILE . C('USER_AUTH_GATEWAY'));
						}
						// 提示错误信息
						$this->error(L('_VALID_ACCESS_'));
					}
				}

			}

		}

	}